package com.gnerv.plug.comment;

import com.gnerv.plug.comment.action.ClassCommentAction;
import com.gnerv.plug.comment.action.SetAuthor;
import com.gnerv.plug.constant.EmbraceSourceInfo;
import com.intellij.openapi.actionSystem.ActionGroup;
import com.intellij.openapi.actionSystem.AnAction;
import com.intellij.openapi.actionSystem.AnActionEvent;
import com.intellij.openapi.actionSystem.CommonDataKeys;
import com.intellij.openapi.vfs.VirtualFile;
import org.jetbrains.annotations.NotNull;
import org.jetbrains.annotations.Nullable;

public class CommentGroupAction extends ActionGroup {

    public CommentGroupAction() {
        super();
    }

    public CommentGroupAction(@Nullable String shortName, boolean popup) {
        super(shortName, popup);
    }

    @NotNull
    @Override
    public AnAction[] getChildren(AnActionEvent e) {
        final VirtualFile file = e.getRequiredData(CommonDataKeys.VIRTUAL_FILE);
        String fileType = file.getFileType().getName();
        if (EmbraceSourceInfo.FILE_TYPE_JAVA.equals(fileType)) {
            return new AnAction[]{
                    new ClassCommentAction("ClassComment", "ClassComment", null),
                    new SetAuthor("SetAuthor", "SetAuthor", null)
            };
        }
        return new AnAction[]{};
    }

}
